/**
 * Created by xu_jiaHui on 2017/4/20.
 */
//故障类型
var userMobile = ""
var reprotProvince;
var reportArea;
var reportRoadName;
var reportStarRoad;
var reportCity;
var reportEndRoad;
var faultType = [{"value": "0", "name": "正常"}, {"value": "1", "name": "膜脱落"}, {"value": "2", "name": "膜淡化"},
    {"value": "3", "name": "逆反射系数不达标"}, {"value": "4", "name": "卷边"}, {"value": "5", "name": "转向"},
    {"value": "6", "name": "非国际"}, {"value": "7", "name": "抱箍缺少"}, {"value": "8", "name": "净空高不达标"},
    {"value": "9", "name": "设置不合理"}, {"value": "10", "name": "缺失"}, {"value": "11", "name": "建议增设"},
    {"value": "12", "name": "与交通组织矛盾"}, {"value": "13", "name": "内容有误"}, {"value": "14", "name": "标牌与标杆不配套"},
    {"value": "15", "name": "非公指示牌"}];
$.getActorId = function (data) {
    var actorId = 0;
    if (data.indexOf("6") >= 0)
        actorId = 6;
    if (data.indexOf("1") >= 0)
        actorId = 1;
    return actorId;
};
var gActorId = $.getActorId(gUserLoginResult.userActors);


function formatXY(n) {
    var number = n + "",
        point = number.indexOf("."),
        len = number.length, len2 = len - point - 1;
    for (; len2 < 6; len2++) {
        number += "0";
    }
    return number;
}

var midHeight;
$.setDefaultNum = function () {
    var windowHeight = $(window).height();
    var headerHeight = $("headArea").height() + 50;
    var footerHieght = 115;
    midHeight = windowHeight - headerHeight - footerHieght;
};
$.setDefaultNum();
var actorId = 0;
if (gUserLoginResult.userActors.indexOf("1") >= 0)
    actorId = 1;
var data;
var pointCollection;
var map;
var machineType;
$(function () {
    /****************创建和初始化地图函数*************************/
    function initMap() {
        createMap();//创建地图
        setMapEvent();//设置地图事件
        addMapControl();//向地图添加控件
    }

    //创建地图函数：
    function createMap() {
        $("#dituContent").css("height", midHeight);
        map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
        map.centerAndZoom(gPoint, 13);//设定地图的中心点和坐标并将地图显示在地图容器中

        if (sessionStorage.outType != 1) {
            $("#machineTypeDiv").hide();
            $.getCoordinate(sessionStorage.outType);
        }
        else
            $.getCoordinate('0');
        $.drawPoint();

        if (sessionStorage.outType == 6 || sessionStorage.outType == 7)
            $.drawPolyLine();

    }

    //地图事件设置函数：
    function setMapEvent() {
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableScrollWheelZoom();//启用地图滚轮放大缩小
        map.disableDoubleClickZoom();//禁用鼠标双击放大
        map.enableKeyboard();//启用键盘上下左右键移动地图
    }

    //地图控件添加函数：
    function addMapControl() {
        //向地图中添加缩放控件
        var ctrl_nav = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE});
        map.addControl(ctrl_nav);

        //向地图中添加比例尺控件
        var ctrl_sca = new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, enableGeolocation: true});
        map.addControl(ctrl_sca);

        var geolocationControl = new BMap.GeolocationControl();
        geolocationControl.addEventListener("locationSuccess", function (e) {

        });
        geolocationControl.addEventListener("locationError", function (e) {
            // 定位失败事件
            alert(e.message);
        });
        map.addControl(geolocationControl);


    }

    /*************************绘制海量点**************************************/
    $.drawPoint = function () {
        if (document.createElement('canvas').getContext) {  // 判断当前浏览器是否支持绘制海量点
            var points = [];  // 添加海量点数据
            for (var i = 0; i < data.length; i++) {
                points.push(new BMap.Point(data[i].longitude, data[i].latitude));
            }
            var options = {
                size: 5,
                shape: 0,
                //color: '#d3140d'
            };
            pointCollection = new BMap.PointCollection(points, options);  // 初始化PointCollection
            map.addOverlay(pointCollection);  // 添加Overlay

            //弹出模态框
            pointCollection.addEventListener('click', function (e) {
                switch (machineType) {
                    case '0':
                        $.showRoadPoleInfo(e.point.lng, e.point.lat);
                        break;
                    case '3':
                        $.showSignalMachineInfo(e.point.lng, e.point.lat);
                        break;
                    case '4':
                        $.showSolarEnergyInfo(e.point.lng, e.point.lat);
                        break;
                    case '8':
                        $.showMonitorInfo(e.point.lng, e.point.lat);
                        break;
                    case '9':
                        $.showCoverInfo(e.point.lng, e.point.lat);
                        break;
                }

            });
        } else {
            alert('请在chrome、safari、IE8+以上浏览器查看');
        }
    };

    /*************************绘制海量点end***********************************/

    /***********************绘制线段*************************************/
    $.drawPolyLine = function () {
        var lng, lat, line, endPoint;
        data.forEach(function (value) {
            line = [];
            lng = value.longitude.split(",");
            lat = value.latitude.split(",");
            lng.forEach(function (t, index) {
                if (t != "") {
                    line.push(new BMap.Point(lng[index], lat[index]));
                    endPoint = new BMap.Point(lng[index], lat[index]);
                }
            });
            var polyline = new BMap.Polyline(line, {strokeColor: "blue", strokeWeight: 2, strokeOpacity: 0.5});
            map.addOverlay(polyline);
            addMarker('../images/end.png', value.elementId, endPoint);
            addMarker('../images/start.png', value.elementId, new BMap.Point(lng[0], lat[0]));
        })
    };

    function addMarker(img, elementId, point) {
        var icon = new BMap.Icon(img, new BMap.Size(40, 33), {//是引用图标的名字以及大小，注意大小要一样
            anchor: new BMap.Size(12, 30)//这句表示图片相对于所加的点的位置
        });
        var mkr = new BMap.Marker(point, {
            icon: icon
        });
        mkr.elementId = elementId;
        map.addOverlay(mkr);
        mkr.addEventListener("click", function (e) {
            switch (machineType) {
                case '6':
                    $.showRoadLineInfo(e.target.elementId);
                    break;
                case '7':
                    $.showGuardrailInfo(e.target.elementId);
                    break;
            }
        });

        mkr.addEventListener("mouseover", function (e) {
            var url = "", func;
            switch (machineType) {
                case '6':
                    url = "../rds_RoadSignMap/getRoadLineInfoById";
                    func = "$.showRoadLineInfo";
                    break;
                case '7':
                    url = "../rds_RoadSignMap/getGuardrailInfoById";
                    func = "$.showGuardrailInfo";
                    break;
            }
            ;
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: {
                    elementId: e.target.elementId
                },
                success: function (msg) {
                    if (msg != null && typeof (msg) != "undefined") {
                        if (msg.isSuccess) {
                            var jsonData = msg.jsonData;
                            var photo = jsonData.photo.split(","), url;
                            if (photo[0])
                                url = "http://hldoss.oss-cn-hangzhou.aliyuncs.com/" + photo[0];
                            else
                                url = "../images/default_photo.png";
                            info = '<div style="text-align:center"><img style="height: 200px" src=' + url + '>' +
                                '<p>ID流水号：' + jsonData.machineId + '</p>' +
                                '<p>地址：' + jsonData.province + ' ' + jsonData.city + ' ' + jsonData.area + '</p>';
                            if (!(machineType == 3 || machineType == 2))
                                info += '<p>' + jsonData.roadName + ' ' + jsonData.startRoad + '起 ' + jsonData.endRoad + '止</p>';
                            else
                                info += '<p>' + jsonData.startRoad + '——' + jsonData.endRoad + '(交汇)</p>';
                            info += '<button style="float: right" onclick="' + func + '(' + e.target.elementId + ')">' +
                                '<i class="glyphicon glyphicon-option-horizontal"></i></button>' +
                                '</div>';
                            var opt = {
                                width: 200
                            };
                            var infoWindow = new BMap.InfoWindow(info, opt);  // 创建信息窗口对象
                            map.openInfoWindow(infoWindow, e.point); //开启信息窗口
                        } else {
                            $.alert("信息获取失败", 2);
                        }
                    } else {
                        $.alert("信息获取失败", 2);
                    }
                }
            });
        })
    }

    /***********************绘制线段end**********************************/

    /*************************获取坐标集**************************************/
    $.getCoordinate = function (type) {
        var url = "";
        machineType = type;
        switch (machineType) {
            case '0':
                url = "../rds_RoadSignMap/getRoadPoleCoordinate4Map";
                break;
            case '2':
                url = "../rds_RoadSignMap/getSignalLampCoordinates4Map";
                break;
            case '3':
                url = "../rds_RoadSignMap/getSignalMachineCoordinate4Map";
                break;
            case '4':
                url = "../rds_RoadSignMap/getSolarEnergyCoordinate4Map";
                break;
            case '5':
                url = "../rds_RoadSignMap/getHighLeverCoordinates4Map";
                break;
            case '6':
                url = "../rds_RoadSignMap/getRoadLineCoordinates4Map";
                break;
            case '7':
                url = "../rds_RoadSignMap/getGuardrailCoordinates4Map";
                break;
            case '8':
                url = "../rds_RoadSignMap/getMonitorCoordinates4Map";
                break;
            case '9':
                url = "../rds_RoadSignMap/getCoverCoordinates4Map";
                break;
        }
        $.ajax({
            url: url,
            type: 'post',
            async: false,
            dataType: 'json',
            data: {
                "orgId": gUserLoginResult.orgId,
                "orgType": gUserLoginResult.orgType,
                "actorId": actorId
            },
            success: function (msg) {
                if (msg != null && typeof (msg) != "undefined") {
                    if (msg.isSuccess == true) {
                        data = msg.jsonData;
                    }
                }
            }
        });
    };
    /*************************获取坐标集**************************************/

    initMap();//创建和初始化地图
    /****************创建和初始化地图函数*************************/

    /************************搜索框****************************/
    function G(id) {
        return document.getElementById(id);
    }

    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
        {
            "input": "suggestId"
            , "location": map
        });

    ac.addEventListener("onhighlight", function (e) {  //鼠标放在下拉列表上的事件
        var str = "";
        var _value = e.fromitem.value;
        var value = "";
        if (e.fromitem.index > -1) {
            value = _value.province + _value.city + _value.district + _value.street + _value.business;
        }
        str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

        value = "";
        if (e.toitem.index > -1) {
            _value = e.toitem.value;
            value = _value.province + _value.city + _value.district + _value.street + _value.business;
        }
        str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
        G("searchResultPanel").innerHTML = str;
    });

    //搜索
    var myValue;
    ac.addEventListener("onconfirm", function (e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;
        myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
        G("searchResultPanel").innerHTML = "onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
        setPlace();
    });

    $("#search-button").click(function () {
        myValue = $("#suggestId").val();
        setPlace();
    });

    $("#suggestId").keydown(function (event) {
        if (event.keyCode == 13) {
            myValue = $("#suggestId").val();
            setPlace();
        }
    });

    function setPlace() {
        // map.clearOverlays();   //清除地图上所有覆盖物
        //$.drawPoint();
        function myFun() {
            var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
            map.centerAndZoom(pp, 15);
            //  map.addOverlay(new BMap.Marker(pp));    //添加标注
        }

        var local = new BMap.LocalSearch(map, { //智能搜索
            onSearchComplete: myFun
        });
        local.search(myValue);
    }

    /************************搜索框end****************************/


    /*********************添加海量点事件*************************/
    pointCollection.addEventListener('mouseover', function (e) {
        var info = "", url = "", func = "";
        var x = formatXY(e.point.lng);
        var y = formatXY(e.point.lat);
        switch (machineType) {
            case '0':
                url = "../rds_RoadSignMap/getRoadPoleInfoByXY";
                func = "$.showRoadPoleInfo";
                break;
            case '2':
                url = "../rds_RoadSignMap/getSignalLampInfoByXY";
                func = "$.showSignalLampInfo";
                break;
            case '3':
                url = "../rds_RoadSignMap/getSignalMachineInfoByXY";
                func = "$.showSignalMachineInfo";
                break;
            case '4':
                url = "../rds_RoadSignMap/getSolarEnergyInfoByXY";
                func = "$.showSolarEnergyInfo";
                break;
            case '5':
                url = "../rds_RoadSignMap/getHighLeverInfoByXY";
                func = "$.showHighLeverInfo";
                break;
            case '8':
                url = "../rds_RoadSignMap/getMonitorInfoByXY";
                func = "$.showMonitorInfo";
                break;
            case '9':
                url = "../rds_RoadSignMap/getCoverInfoByXY";
                func = "$.showCoverInfo";
                break;
        }
        $.ajax({
            url: url,
            type: 'post',
            // async: false,
            dataType: 'json',
            data: {
                "longitude": x,
                "latitude": y
            },
            success: function (msg) {
                if (msg != null && typeof (msg) != "undefined") {
                    if (msg.isSuccess) {
                        var jsonData = msg.jsonData;
                        info = '<div style="text-align:center"><img style="height: 200px" src=' + jsonData.photo + '>' +
                            '<p>ID流水号：' + jsonData.machineId + '</p>' +
                            '<p>地址：' + jsonData.province + ' ' + jsonData.city + ' ' + jsonData.area + '</p>';
                        if (!(machineType == 3 || machineType == 2))
                            info += '<p>' + jsonData.roadName + ' ' + jsonData.startRoad + '起 ' + jsonData.endRoad + '止</p>';
                        else
                            info += '<p>' + jsonData.startRoad + '——' + jsonData.endRoad + '(交汇)</p>';
                        info += '<button style="float: right" onclick="' + func + '(' + x + ',' + y + ')">' +
                            '<i class="glyphicon glyphicon-option-horizontal"></i></button>' +
                            '</div>';
                        var opt = {
                            width: 200
                        };
                        var infoWindow = new BMap.InfoWindow(info, opt);  // 创建信息窗口对象
                        map.openInfoWindow(infoWindow, e.point); //开启信息窗口
                    } else {
                        $.alert("信息获取失败", 2);
                    }
                } else {
                    $.alert("信息获取失败", 2);
                }
            }
        });

    });


    /*********************添加海量点事件end*************************/


    $("#stateBtn").click(function () {
        bootbox.confirm({
            buttons: {
                confirm: {
                    label: '<i class="fa fa-check"></i> 确定',
                    className: 'btn btn-primary btn-flat'
                },
                cancel: {
                    label: '<i class="fa fa-close"></i> 取消',
                    className: 'btn btn-warning btn-flat pull-left'
                }
            },
            message: '<i class="fa fa-question-circle-o"></i> <b class="customer-title">确定修改状态为正常?</b>',
            callback: function (result) {
                if (result) {
                    $("#showReasonModal").modal("hide");
                    $.showReportFaultInfo(Jdata);
                }
            }
        })
    });


    //获取用户电话
    $.ajax({
        url: "../rds_user/getUserById",
        type: "POST",
        async: false,
        data: {
            userId: gUserLoginResult.userId
        },
        success: function (msg) {
            if (msg != null && typeof(msg) != "undefined") {
                if (msg.isSuccess == true) {
                    userMobile = msg.jsonData.userMobile;
                } else {
                    $.alert("获取监管单位数据失败", 2);
                }
            }
        }
    });

    /******************设备显示切换*******************/
    $("#machineType").change(function () {
        map.clearOverlays();
        var type = $(this).val();
        $.getCoordinate(type);
        if (!(type == 6 || type == 7))
            $.drawPoint();
        else
            $.drawPolyLine();

    });
    /******************设备显示切换*******************/

});

$(".image").click(function () {
    if($(this).attr("id")!="roadLinePic"&&$(this).attr("id")!="guardrailPic")
        $.showPicModal($(this).attr("src"));
});

$.showPicListModal = function (picList) {
    console.log(11111);
    dex = 0;//图片轮转置0
    picList = picList.split(",");
    var pic = $('.img-content');
    pic.html("").css("top", "0px");
    for (var i in picList) {
        if (picList[i] != "" && picList[i].indexOf("http") < 0)
            pic.append("<img src='http://hldoss.oss-cn-hangzhou.aliyuncs.com/" + picList[i] + "'>")
        else
            pic.append("<img src='" + picList[i] + "'>")
    }
    $(".img-content img[src]:first").show();
    $("#showPicList").modal({
        backdrop: 'static',
        keyboard: false,
        show: true
    })
};

/***********************展示标杆信息***********************************/
$.showRoadPoleInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getRoadPoleByXY",
        type: 'post',
        async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                var jsonData = msg.jsonData[0];
                $("#myDiv").empty();
                reprotProvince = jsonData.province;
                reportArea = jsonData.area;
                reportRoadName = jsonData.roadName;
                reportStarRoad = jsonData.startRoad;
                reportEndRoad = jsonData.endRoad;
                reportCity = jsonData.city;
                $("#projectNo").html("<b>项目编号:</b>" + jsonData.projectNumber);
                $("#address").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " " + jsonData.roadName + " " + jsonData.startRoad + "起 " + jsonData.endRoad + "止");
                var temp = "0";
                if (jsonData.roadPoleShape == 0)
                    temp = "单直杆";
                if (jsonData.roadPoleShape == 1)
                    temp = "双直杆";
                if (jsonData.roadPoleShape == 2)
                    temp = "单挑杆";
                if (jsonData.roadPoleShape == 3)
                    temp = "双挑杆";
                if (jsonData.roadPoleShape == 4)
                    temp = "二F杆";
                if (jsonData.roadPoleShape == 5)
                    temp = "三F杆";
                if (jsonData.roadPoleShape == 6)
                    temp = "门架";
                $("#shape").html(temp);
                if (jsonData.roadPoleSecurity == 0)
                    temp = "安全";
                if (jsonData.roadPoleSecurity == 1)
                    temp = "不安全";
                $("#security").html(temp);
                if (jsonData.roadPoleBridge == 0)
                    temp = "否";
                if (jsonData.roadPoleBridge == 1)
                    temp = "是";
                $("#bridge").html(temp);

                $("#create").html(jsonData.userName);
                $("#size").html(jsonData.roadPoleSize);
                $("#company").html(jsonData.orgName);
                $("#mainOrg").html(jsonData.mainOrgName);

                if (machineType === "0") {
                    $.ajax({
                        url: "../rds_roadSignManageController/getRoadSignCollect",
                        type: 'post',
                        async: false,
                        dataType: 'json',
                        data: {
                            'roadPoleId': jsonData.roadPoleId
                        },
                        success: function (msg) {
                            if (msg != null && typeof (msg) != "undefined") {
                                if (msg.isSuccess == true) {
                                    var Data = msg.jsonData;
                                    for (var i = 0; i < Data.length; i++) {
                                        var data = Data[i];
                                        var roadSignLight;
                                        var roadSignShape;
                                        var roadSignInstallType;
                                        var roadSignMaterial;
                                        var roadSignDirection;
                                        var roadSignType;
                                        var roadSignBug;
                                        var roadSignSize = data.roadSignSize;
                                        var environment = "日常使用";
                                        if (data.environment == 1)
                                            environment = "施工配合";
                                        var roadSignFixed = "扎带";
                                        if (data.roadSignFixed == 1)
                                            roadSignFixed = "抱箍";
                                        var roadSignSecurity = "安全";
                                        if (data.roadSignSecurity != 0) {
                                            roadSignSecurity = "不安全";
                                        }

                                        switch (data.roadSignInstallType) {
                                            case 0:
                                                roadSignInstallType = "单标志";
                                                break;
                                            case 1:
                                                roadSignInstallType = "合杆";
                                                break;
                                            case 2:
                                                roadSignInstallType = "借杆";
                                                break;
                                        }
                                        switch (data.roadSignLight) {
                                            case 0:
                                                roadSignLight = "反光";
                                                break;
                                            case 1:
                                                roadSignLight = "发光";
                                                break;
                                            case 2:
                                                roadSignLight = "照明";
                                                break;
                                        }
                                        switch (data.roadSignMaterial) {
                                            case 0:
                                                roadSignMaterial = "铝板";
                                                break;
                                            case 1:
                                                roadSignMaterial = "塑料板";
                                                break;
                                            case 2:
                                                roadSignMaterial = "其他";
                                                break;

                                        }
                                        switch (data.roadSignShape) {
                                            case 0: {
                                                roadSignShape = "圆形";
                                                break;
                                            }
                                            case 1: {
                                                roadSignShape = "八角形";
                                                break;
                                            }
                                            case 2: {
                                                roadSignShape = "正三角";
                                                break;
                                            }
                                            case 3: {
                                                roadSignShape = "倒三角";
                                                break;
                                            }
                                            case 4: {
                                                roadSignShape = "矩形";
                                                break;
                                            }
                                            case 5: {
                                                roadSignShape = "方形";
                                                break;
                                            }
                                        }
                                        switch (data.roadSignDirection) {
                                            case 0:
                                                roadSignDirection = "东";
                                                break;
                                            case 1:
                                                roadSignDirection = "南";
                                                break;
                                            case 2:
                                                roadSignDirection = "西";
                                                break;
                                            case 3:
                                                roadSignDirection = "北";
                                                break;
                                        }
                                        switch (data.roadSignType) {
                                            case 0:
                                                roadSignType = "警告标志";
                                                break;
                                            case 1:
                                                roadSignType = "禁令标志";
                                                break;
                                            case 2:
                                                roadSignType = "指示标志";
                                                break;
                                            case 3:
                                                roadSignType = "指路标志";
                                                break;
                                            case 4:
                                                roadSignType = "旅游标志";
                                                break;
                                            case 5:
                                                roadSignType = "辅助标志";
                                                break;
                                            case 6:
                                                roadSignType = "作业标志";
                                                break;
                                            case 7:
                                                roadSignType = "告示标志";
                                                break;
                                        }
                                        switch (data.roadSignBug) {
                                            case 0:
                                                roadSignBug = "正常";
                                                break;
                                            case 1:
                                                roadSignBug = "膜脱落";
                                                break;
                                            case 2:
                                                roadSignBug = "膜淡化";
                                                break;
                                            case 3:
                                                roadSignBug = "逆反射系数不达标";
                                                break;
                                            case 4:
                                                roadSignBug = "卷边";
                                                break;
                                            case 5:
                                                roadSignBug = "转向";
                                                break;
                                            case 6:
                                                roadSignBug = "非国际";
                                                break;
                                            case 7:
                                                roadSignBug = "抱箍缺少";
                                                break;
                                            case 8:
                                                roadSignBug = "净空高不达标";
                                                break;
                                            case 9:
                                                roadSignBug = "设置不合理";
                                                break;
                                            case 10:
                                                roadSignBug = "缺失";
                                                break;
                                            case 11:
                                                roadSignBug = "建议增设";
                                                break;
                                            case 12:
                                                roadSignBug = "与交通组织矛盾";
                                                break;
                                            case 13:
                                                roadSignBug = "内容有误";
                                                break;
                                            case 14:
                                                roadSignBug = "标牌与标杆不配套";
                                                break;
                                            case 15:
                                                roadSignBug = "非公指示牌";
                                                break;
                                        }
                                        var n = i + 1;
                                        var html = "<table class=\"table table-bordered table-striped\">\n" +
                                            " <tr>\n" +
                                            "<th>标牌" + n + "<th>";
                                        if (gActorId == 0) {
                                            html += "<th><button type='button' class='btn btn-danger btn-xs btn-flat'>" +
                                                "无权限</button><th>";
                                        } else if (data.roadSignIsComplete == 0) {
                                            html += "<th><button type='button' class='btn btn-danger btn-xs btn-flat' >" +
                                                "未审核</button><th>";
                                        } else {
                                            if (data.reportState == 1)
                                                html += "<th><button type='button' class='btn btn-default btn-xs btn-flat' >" +
                                                    "故障申报中</button><th>";
                                            else if (data.reportState == 2)
                                                html += "<th><button type='button' id='bTn" + data.roadSignId + "' onclick='$.showReason(" + JSON.stringify(data) + ")' class='btn btn-danger btn-xs btn-flat' >" +
                                                    "申报失败点击查看原因</button><th>";
                                            else if (data.reportState == 3)
                                                html += "<th><button type='button' class='btn btn-default btn-xs btn-flat' >" +
                                                    "故障处理中</button><th>";
                                            else
                                                html += "<th><button type='button' id='btn" + data.roadSignId + "' class='btn btn-primary btn-xs btn-flat' onclick='$.showReportFaultInfo(" + JSON.stringify(data) + ")' >" +
                                                    "<span class='glyphicon glyphicon-check' aria-hidden='true' ></span>故障上报</button><th>";
                                        }
                                        html += "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td  rowspan=\"8\" colspan=\"3\"><img onclick=\"$.showPicModal('" + data.roadSignPic + "')\" style=\"width: 230px;height:270px; cursor: pointer\" src=\"" + data.roadSignPic + "\"></td>\n" +
                                            "                            <td><b>标志分类：</b></td>\n" +
                                            "                            <td>" + roadSignType + "</td>\n" +
                                            "                            <td><b>标志含义:</b></td>\n" +
                                            "                            <td>" + roadSignType.substring(0, 1) + "" + data.roadSignMeaning + "</td>\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>存在问题:</b></td>\n" +
                                            "                            <td>" + roadSignBug + "</td>\n" +
                                            "                            <td><b>安全状况:</b></td>\n" +
                                            "                            <td>" + roadSignSecurity + "</td>\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>标志形状:</b></td>\n" +
                                            "                            <td>" + roadSignShape + "</td>\n" +
                                            "                            <td><b>标牌尺寸:</b></td>\n" +
                                            "                            <td>" + roadSignSize + "</td>\n" +
                                            "\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>标志材料:</b></td>\n" +
                                            "                            <td>" + roadSignMaterial + "</td>\n" +
                                            "                            <td><b>采集人 :</b></td>\n" +
                                            "                            <td>" + data.userName + "</td>\n" +
                                            "\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>光源显示:</b></td>\n" +
                                            "                            <td>" + roadSignLight + "</td>\n" +
                                            "                            <td><b>安装方式:</b></td>\n" +
                                            "                            <td>" + roadSignInstallType + "</td>\n" +
                                            "\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>固定方式:</b></td>\n" +
                                            "                            <td>" + roadSignFixed + "</td>\n" +
                                            "                            <td><b>安装日期:</b></td>\n" +
                                            "                            <td>" + data.roadSignInstallTime + "</td>\n" +
                                            "\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>安装公司:</b></td>\n" +
                                            "                            <td>" + data.installOrg + "</td>\n" +
                                            "                            <td><b>使用场景:</b></td>\n" +
                                            "                            <td>" + environment + "</td>\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>保修期 :</b></td>\n" +
                                            "                            <td>" + data.defectsLiabilityPeriod + "年</td>\n" +
                                            "                            <td><b>使用年限:</b></td>\n" +
                                            "                            <td>" + data.serviceLife + "年</td>\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                            <td><b>标志朝向:</b></td>\n" +
                                            "                            <td>" + roadSignDirection + "</td>\n" +
                                            "                            <td><b>备注说明:</b></td>\n" +
                                            "                            <td colspan=\"7\">" + data.roadSignRemark + "</td>\n" +
                                            "                        </tr>\n" +
                                            "                        <tr>\n" +
                                            "                        </table>";
                                        $("#myDiv").append(html);
                                    }
                                } else {
                                    $.alert("数据操作失败", 2);
                                }
                            } else {
                                $.alert('系统错误，请联系管理员', 2);
                            }
                        }
                    });
                }

                $("#img").attr("src", jsonData.roadPolePic);
                $("#modal-AllInformation").modal({
                    backdrop: 'static',
                    keyboard: false,
                    show: true
                });
            }
        }

    })
}
/***********************展示标杆信息end***********************************/

/***********************展示信号机信息***********************************/
$.showSignalMachineInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getSignalMachineInfoByXY",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    $("#signalMachineProjectNumber").html(jsonData.projectNumber);
                    $("#signalMachinePic").attr("src", jsonData.photo);
                    $("#signalMachineAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#signalMachineBrand").html(jsonData.brand);
                    $("#signalMachineNumber").html(jsonData.number);
                    $("#signalMachineAlarm").html(function () {
                        return jsonData.alarm = 0 ? "无" : "有";
                    });
                    $("#signalMachineCreator").html(jsonData.creatorName);
                    $("#signalMachineInstallTime").html(jsonData.installTime);
                    $("#signalMachineInstallOrg").html(jsonData.installOrg);
                    $("#signalMachineServiceLife").html(jsonData.serviceLife + "年");
                    $("#signalMachinePeriod").html(jsonData.period + "年");
                    $("#signalMachineOrg").html(jsonData.orgName);
                    $("#signalMachineMainOrg").html(jsonData.mainOrgName);
                    $("#signalMachineInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
};
/***********************展示信号机信息end**********************************/


/***********************展示太阳能信息***********************************/
$.showSolarEnergyInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getSolarEnergyInfoByXY",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    $("#solarEnergyProjectNumber").html(jsonData.projectNumber);
                    $("#solarEnergyPic").attr("src", jsonData.photo);
                    $("#solarEnergyAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.roadName + " " + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#solarEnergyBrand").html(jsonData.brand);
                    $("#solarEnergyNumber").html(jsonData.number);
                    $("#solarEnergyStyle").html(function () {
                        return jsonData.style = 0 ? "固定式" : "移动式";
                    });
                    switch (jsonData.type) {
                        case 0:
                            $("#solarEnergyType").html("爆闪灯单面");
                            break;
                        case 1:
                            $("#solarEnergyType").html("爆闪灯双面");
                            break;
                        case 2:
                            $("#solarEnergyType").html("移动灯两相位");
                            break;
                        case 3:
                            $("#solarEnergyType").html("移动灯多相位");
                            break;
                        case 4:
                            $("#solarEnergyType").html("标牌");
                            break;
                    }
                    switch (jsonData.material) {
                        case 0:
                            $("#solarEnergyMaterial").html("铁质");
                            break;
                        case 1:
                            $("#solarEnergyMaterial").html("塑料");
                            break;
                        case 2:
                            $("#solarEnergyMaterial").html("铝质");
                            break;
                        case 3:
                            $("#solarEnergyMaterial").html("其他");
                            break;
                    }
                    $("#solarEnergyCreator").html(jsonData.creatorName);
                    $("#solarEnergyInstallTime").html(jsonData.installTime);
                    $("#solarEnergyInstallOrg").html(jsonData.installOrg);
                    $("#solarEnergyServiceLife").html(jsonData.serviceLife + "年");
                    $("#solarEnergyPeriod").html(jsonData.period + "年");
                    $("#solarEnergyOrg").html(jsonData.orgName);
                    $("#solarEnergyMainOrg").html(jsonData.mainOrgName);
                    $("#solarEnergyInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
}
/***********************展示太阳能信息end**********************************/

/***********************展示信号灯信息**********************************/
$.showSignalLampInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getSignalLampInfoByXY",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    var selectType;
                    jsonData.types.length == 0 ? selectType = "未选择类型" :
                        jsonData.types.length == 1 ? selectType = jsonData.types :
                            selectType = jsonData.types.substring(0, jsonData.types.length - 1);
                    $("#signalLampType").html(selectType + "(点击查看)");
                    $("#signalLampProjectNumber").html(jsonData.projectNumber);
                    $("#signalLampPic").attr("src", jsonData.photo);
                    $("#signalLampAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#signalLampBrand").html(jsonData.brand);
                    $("#signalLampNumber").html(jsonData.number);
                    $("#signalLampCreator").html(jsonData.creatorName);
                    $("#signalLampInstallTime").html(jsonData.installTime);
                    $("#signalLampInstallOrg").html(jsonData.installOrg);
                    $("#signalLampServiceLife").html(jsonData.serviceLife + "年");
                    $("#signalLampPeriod").html(jsonData.period + "年");
                    $("#signalLampOrg").html(jsonData.orgName);
                    $("#signalLampMainOrg").html(jsonData.mainOrgName);
                    $("#signalLampInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
};

$("#signalLampType").click(function () {
    var flag = $(this).html().indexOf("(点击查看)");
    var checkList = $(this).html().substring(0, flag).split(",");
    var len = checkList.length;
    // checkList[len - 1] = checkList[len - 1].replace("(点击选择)", "");
    for (var i = 0; i < len; i++) {
        $("#check" + checkList[i] + "").prop("checked", "checked");
    }
    $("#signalLampTypeSelect4Map input").attr("disabled", true);
    $("#signalLampTypeSelect4Map").modal({
        backdrop: 'static',
        keyboard: false,
        show: true
    })
});
/***********************展示信号灯信息end**********************************/

/***********************展示标线信息**********************************/
$.showRoadLineInfo = function (roadLineId) {
    $.ajax({
        url: "../rds_RoadSignMap/getRoadLineInfoById",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            elementId: roadLineId
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    var photo = jsonData.photo.split(","), url;
                    if (photo[0])
                        url = "http://hldoss.oss-cn-hangzhou.aliyuncs.com/" + photo[0];
                    else
                        url = "../images/default_photo.png";
                    $("#roadLineProjectNumber").html(jsonData.projectNumber);
                    $("#roadLinePic").attr("src", url);
                    $("#roadLinePic").attr("onclick", "$.showPicListModal('"+jsonData.photo+"')");
                    $("#roadLineAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.roadName + " " + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#roadLineNumber").html(jsonData.number);
                    $("#roadLineCreator").html(jsonData.creatorName);
                    $("#roadLineInstallTime").html(jsonData.installTime);
                    $("#roadLineInstallOrg").html(jsonData.installOrg);
                    $("#roadLineServiceLife").html(jsonData.serviceLife + "年");
                    $("#roadLinePeriod").html(jsonData.period + "年");
                    $("#roadLineOrg").html(jsonData.orgName);
                    var graphic, type;
                    switch (jsonData.type) {
                        case  0:
                            type = "指示";
                            break;
                        case 1:
                            type = "禁止";
                            break;
                        case 2:
                            type = "警告";
                            break;
                        case 3:
                            type = "其他";
                            break;
                        case 4:
                            type = "警示柱";
                            break;
                    }
                    switch (jsonData.graphic) {
                        case 0:
                            graphic = "纵向"+type+"标线";
                            break;
                        case 1:
                            graphic = "横向"+type+"标线";
                            break;
                        case 2:
                            graphic = "其他"+type+"标线";
                            break;
                        default :
                            graphic = "————";
                            break;
                    }
                    if (jsonData.type == 3 || jsonData.type == 4)
                        $("#roadLineGraphic").html("————");
                    else
                        $("#roadLineGraphic").html(graphic);
                    $("#roadLineType").html(type + "标线");
                    $("#roadLineMainOrg").html(jsonData.mainOrgName);
                    $("#roadLineInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
}
/***********************展示标线信息end**********************************/

/***********************展示标线信息**********************************/
$.showGuardrailInfo = function (guardrailId) {
    $.ajax({
        url: "../rds_RoadSignMap/getGuardrailInfoById",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            elementId: guardrailId
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    var photo = jsonData.photo.split(","), url;
                    if (photo[0])
                        url = "http://hldoss.oss-cn-hangzhou.aliyuncs.com/" + photo[0];
                    else
                        url = "../images/default_photo.png";
                    $("#guardrailProjectNumber").html(jsonData.projectNumber);
                    $("#guardrailPic").attr("src", url);
                    $("#guardrailPic").attr("onclick", "$.showPicListModal('"+jsonData.photo+"')");
                    $("#guardrailAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.roadName + " " + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#guardrailNumber").html(jsonData.number);
                    $("#guardrailCreator").html(jsonData.creatorName);
                    $("#guardrailInstallTime").html(jsonData.installTime);
                    $("#guardrailInstallOrg").html(jsonData.installOrg);
                    $("#guardrailServiceLife").html(jsonData.serviceLife + "年");
                    $("#guardrailPeriod").html(jsonData.period + "年");
                    $("#guardrailOrg").html(jsonData.orgName);
                    var material, type, color;
                    switch (jsonData.material) {
                        case 0:
                            material = "钢护栏";
                            break;
                        case 1:
                            material = "塑钢护栏";
                            break;
                        case 2:
                            material = "铁护栏";
                            break;
                        case 3:
                            material = "其他护栏";
                            break;
                    }
                    switch (jsonData.color) {
                        case 0:
                            color = "蓝色";
                            break;
                        case 1:
                            color = "黄色";
                            break;
                        case 2:
                            color = "绿色";
                            break;
                        case 3:
                            color = "其他";
                            break;
                    }
                    switch (jsonData.type) {
                        case  0:
                            type = "中央分隔带护栏";
                            break;
                        case 1:
                            type = "机非分隔带护栏";
                            break;
                        case 2:
                            type = "人行道隔离护栏";
                            break;
                        case 3:
                            type = "公共汽车专用道护栏";
                            break;
                        case 4:
                            type = "普通隔离护栏";
                            break;
                    }
                    $("#guardrailMaterial").html(material);
                    $("#guardrailColor").html(color);
                    $("#guardrailType").html(type);
                    $("#guardrailMainOrg").html(jsonData.mainOrgName);
                    $("#guardrailInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
}
/***********************展示标线信息end**********************************/

/***********************展示窨井信息**********************************/
$.showCoverInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getCoverInfoByXY",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    $("#coverProjectNumber").html(jsonData.projectNumber);
                    $("#coverPic").attr("src", jsonData.photo);
                    $("#coverAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.roadName + " " + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#coverBrand").html(jsonData.brand);
                    $("#coverNumber").html(jsonData.number);
                    $("#coverCreator").html(jsonData.creatorName);
                    $("#coverInstallTime").html(jsonData.installTime);
                    $("#coverInstallOrg").html(jsonData.installOrg);
                    $("#coverServiceLife").html(jsonData.serviceLife + "年");
                    $("#coverPeriod").html(jsonData.period + "年");
                    $("#coverOrg").html(jsonData.orgName);
                    $("#coverMainOrg").html(jsonData.mainOrgName);
                    $("#coverSize").html(jsonData.size);
                    jsonData.shape == 0 ? $("#coverShape").html("长方形") : $("#coverShape").html("矩形");
                    switch (jsonData.material) {
                        case 0:
                            $("#coverMaterial").html("树脂");
                            break;
                        case 1:
                            $("#coverMaterial").html("水泥");
                            break;
                        case 2:
                            $("#coverMaterial").html("球墨");
                            break;
                        case 3:
                            $("#coverMaterial").html("其他");
                            break;
                    }
                    $("#coverInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
}
/***********************展示窨井信息end**********************************/


/***********************展示限高杆信息**********************************/
$.showHighLeverInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getHighLeverInfoByXY",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    $("#highLeverProjectNumber").html(jsonData.projectNumber);
                    $("#highLeverPic").attr("src", jsonData.photo);
                    $("#highLeverAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.roadName + " " + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#highLeverBrand").html(jsonData.brand);
                    $("#highLeverNumber").html(jsonData.number);
                    $("#highLeverCreator").html(jsonData.creatorName);
                    $("#highLeverInstallTime").html(jsonData.installTime);
                    $("#highLeverInstallOrg").html(jsonData.installOrg);
                    $("#highLeverServiceLife").html(jsonData.serviceLife + "年");
                    $("#highLeverPeriod").html(jsonData.period + "年");
                    $("#highLeverOrg").html(jsonData.orgName);
                    $("#highLeverMainOrg").html(jsonData.mainOrgName);
                    $("#highLeverSize").html(jsonData.size);
                    jsonData.shape == 0 ? $("#highLeverShape").html("长方形") : $("#highLeverShape").html("矩形");
                    switch (jsonData.material) {
                        case 0:
                            $("#highLeverMaterial").html("树脂");
                            break;
                        case 1:
                            $("#highLeverMaterial").html("水泥");
                            break;
                        case 2:
                            $("#highLeverMaterial").html("球墨");
                            break;
                        case 3:
                            $("#highLeverMaterial").html("其他");
                            break;
                    }
                    $("#highLeverInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
}
/***********************展示限高杆信息end**********************************/

/***********************展示监控箱信息**********************************/
$.showMonitorInfo = function (x, y) {
    x = formatXY(x);
    y = formatXY(y);
    $.ajax({
        url: "../rds_RoadSignMap/getMonitorInfoByXY",
        type: 'post',
        // async: false,
        dataType: 'json',
        data: {
            "longitude": x,
            "latitude": y
        },
        success: function (msg) {
            if (msg != null && typeof (msg) != "undefined") {
                if (msg.isSuccess) {
                    var jsonData = msg.jsonData;
                    $("#monitorProjectNumber").html(jsonData.projectNumber);
                    $("#monitorPic").attr("src", jsonData.photo);
                    $("#monitorAddress").html(jsonData.province + " " + jsonData.city + " " + jsonData.area + " "
                        + jsonData.roadName + " " + jsonData.startRoad + "——" + jsonData.endRoad + "(交汇)");
                    $("#monitorBrand").html(jsonData.brand);
                    $("#monitorNumber").html(jsonData.number);
                    $("#monitorCreator").html(jsonData.creatorName);
                    $("#monitorInstallTime").html(jsonData.installTime);
                    $("#monitorInstallOrg").html(jsonData.installOrg);
                    $("#monitorServiceLife").html(jsonData.serviceLife + "年");
                    $("#monitorPeriod").html(jsonData.period + "年");
                    $("#monitorOrg").html(jsonData.orgName);
                    $("#monitorMainOrg").html(jsonData.mainOrgName);
                    $("#monitorSize").html(jsonData.size);

                    var direction, shape;
                    switch (jsonData.direction) {
                        case 0:
                            direction = "东";
                            break;
                        case 1:
                            direction = "南";
                            break;
                        case 2:
                            direction = "西";
                            break;
                        case 3:
                            direction = "北";
                            break;
                    }
                    $("#monitorDirection").html(direction);
                    switch (jsonData.shape) {
                        case 0:
                            shape = "八角";
                            break;
                        case 1:
                            shape = "圆管";
                            break;
                        case 2:
                            shape = "等径";
                            break;
                        case 3:
                            shape = "变径";
                            break;
                        case 4:
                            shape = "锥形";
                            break;
                    }
                    $("#monitorPoleShape").html(shape);
                    $("#monitorPoleSize").html(jsonData.poleSize);
                    $("#MonitorPosition").html(jsonData.position == 0 ? "地面" : "杆上");
                    $("#MonitorSize").html(jsonData.size);
                    $("#monitorInfoModal").modal({
                        backdrop: 'static',
                        keyboard: false,
                        show: true
                    });
                } else {
                    $.alert("信息获取失败", 2);
                }
            } else {
                $.alert("信息获取失败", 2);
            }
        }
    })
}
/***********************展示监控箱信息end**********************************/




//展示申报失败原因
var Jdata;
$.showReason = function (jsonData) {
    Jdata = jsonData;
    $.ajax({
        url: "../rds_fault/getCheckBackBySignFaultId",
        type: "post",
        async: false,
        data: {
            "roadSignId": jsonData.roadSignId
        },
        success: function (msg) {
            if (msg != null && typeof(msg) != "undefined") {
                if (msg.isSuccess == true) {
                    $("#reason").val(msg.jsonData);
                }
                else
                    $.alert("系统错误，请联系管理员", 2);
            }
        }

    });
    $("#1roadSignId").val(roadSignId);
    $("#showReasonModal").modal({
        backdrop: 'static',
        keyboard: false,
        show: true
    });
};

$.showReportFaultInfo = function (data) {
    if (gActorId == 0) {
        $.alert("对不起，您没有权限", 3);
    } else {
        //故障类型初始化
        var faultTypeInit = "";
        for (var i = 0; i < faultType.length; i++) {
            faultTypeInit += "<option value='" + faultType[i].value + "'>" + faultType[i].name + "</option>";
        }
        $("#addfault_signFaultType").append(faultTypeInit);
        $("#addfault_signFaultPeopleName").text(gUserLoginResult.userName);
        $("#addfault_signFaultPeopleMobile").text(userMobile);
        $("#addfault_roadName").text(reportRoadName);
        $("#addfault_address").text(reprotProvince + "" + reportCity + "" + reportArea + " " + reportRoadName + " " + reportStarRoad + "(起)--" + reportEndRoad + "(止)");
        // $("#reportBtn").hide();
        $("#addfault_roadSignId").val(data.roadSignId)
        $("#addfault_signFaultPic").attr("src", data.roadSignPic)
        $("#addfault_orgId").val(data.orgId);
        $("#addfault_mainOrgId").val(data.mainOrgId);
        $("#addfault_signBtn").hide()
        $("#addfaultModalLabel").text("故障上报");
        $("#addfaultModal").modal({
            backdrop: 'static',
            keyboard: false,
            show: true
        });
    }
};

//故障上报的验证
$.reportFault = function () {
    var repairAmount = $("#addfault_repairAmount").val();
    if (repairAmount == "") {
        repairAmount = 0.00;
    }
    console.log(repairAmount);
    if ($("#addfault_address").text() == "" && $("#addfault_roadName").text() == "") {
        $.alert("请选择标牌", 2);
    } else if ($("#addfault_signFaultReason").val() == "") {
        $.alert("请填写故障原因", 2);
    } else {
        $.ajax({
            url: "../rds_fault/reportSignFault",
            type: "post",
            dataType: "json",
            data: {
                roadSignId: $("#addfault_roadSignId").val(),
                signFaultPeopleId: gUserLoginResult.userId,
                signFaultLevel: $("#addfault_signFaultLevel").val(),
                signFaultType: $("#addfault_signFaultType").val(),
                signFaultPic: $("#addfault_signFaultPic").attr("src"),
                signFaultReason: $("#addfault_signFaultReason").val(),
                repairAmount: repairAmount,
                orgId: $("#addfault_orgId").val(),
                mainOrgId: $("#addfault_mainOrgId").val()
            },
            success: function (msg) {
                if (msg != null && typeof (msg) != "undefined") {
                    if (msg.isSuccess == true) {
                        $("#addfaultModal").modal("hide");
                        $.alert("申报成功，等待内部审核", 1);
                        $.clearModal($('#form-AllInformation'), $('#modal-AllInformation'));
                        $("#addfault_signFaultLevel").val(1);
                        $("#addfault_signFaultType").val(0);
                        $("#addfault_signFaultPic").attr("src", "../images/default_photo.png");
                        $("#addfault_roadName").html("");
                        $("#addfault_address").html("");
                        $("#addfault_repairAmount").val("");
                        $("#addfault_signFaultReason").val("");
                    } else {
                        $.alert("系统错误", 2);
                    }
                } else {
                    $.alert('系统错误，请联系管理员', 2);
                }
            },
            error: function () {
                $.alert("系统错误！", 4);
            }
        });
    }
};

function textdown(e) {
    textevent = e;
    if (textevent.keyCode == 8) {
        return;
    }
    if ($("#reportFaultReason").val().length >= 100) {
        $.alert("最多输入100个字", 2);
        if (!document.all) {
            textevent.preventDefault();
        }
        else {
            textevent.returnValue = false;
        }
    }
}

function textup() {
    var s = $("#reportFaultReason").val();
//判断ID为text的文本区域字数是否超过1000个
    if (s.length > 100) {
        $("#reportFaultReason").val(s.substring(0, 100));
    }
}

// 打开上传modal框
$.openUpPic = function () {
    $("#upPictureModal").modal({
        backdrop: 'static',
        keyboard: true,
        show: true
    });
};

// 关闭上传modal框
$.closeUpPhModal = function () {
    $("#upPictureModal").modal("hide");
    $("#ossfile").empty();
    clearOssData();
};

//获取图片信息
$.doneUpPhoto = function () {
    var fileInfo = getOssFileInfo();
    fileUrl = fileInfo[0].fileUrl;
    $("#reportFaultPic").attr("src", fileUrl);
    $.closeUpPhModal();
};

//判断文件类型(在需要的js文件添加，文件名务必保持一致)
function judgeFileType(suffix) {
    //图片文件
    if (!(suffix == ".jpg" || suffix == ".JPG" || suffix == ".png" || suffix == ".PNG" ||
            suffix == ".jpeg" || suffix == ".JPEG" || suffix == ".gif" || suffix == ".GIF" ||
            suffix == ".bmp" || suffix == ".BMP")) {
        alert("请选择图片文件！");
        return false;
    }
}

//限制金额输入为0.00
function onlyNumber(obj) {

    //得到第一个字符是否为负号
    var t = obj.value.charAt(0);
    //先把非数字的都替换掉，除了数字和.
    obj.value = obj.value.replace(/[^\d\.]/g, '');
    //必须保证第一个为数字而不是.
    obj.value = obj.value.replace(/^\./g, '');
    //保证只有出现一个.而没有多个.
    obj.value = obj.value.replace(/\.{2,}/g, '.');
    //保证.只出现一次，而不能出现两次以上
    obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
    //只能输入两位小数
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
    //如果第一位是负号，则允许添加
    if (t == '-') {


    }

}


/************图片轮转实现2*************************/
function next2() {
    var $imgList = $(".img-content img[src]");
    $imgList.eq(dex).hide();
    if (dex == $imgList.length - 1)
        dex = 0;
    else dex++;
    $imgList.eq(dex).fadeIn()
}

function prev2() {
    var $imgList = $(".img-content img[src]");
    $imgList.eq(dex).hide();
    if (dex == 0)
        dex = $imgList.length - 1;
    else dex--;
    $imgList.eq(dex).fadeIn()
}

var $next2=_debounce(next2, 200)
var $prev2=_debounce(prev2, 200)

$(".next2").click($next2);

$(".prev2").click($prev2);